package com.lmk.qs.jdbc;


import com.lmk.qs.utils.JDBCUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class test05 {
    public static void main(String[] args) {
             Connection connection=null;
             int  i=0;
             Statement st=null;
             ResultSet rs=null;


        try {
           connection= JDBCUtil.getConnection();
           //添加某一条数据
           String str1="insert into emp values (null,'王五','男',15688,123546,2)";
           //修改一条数据
            String  str2= "update emp set name='二哈' where name='Gai'";
            //删除一条数据
            String str3="delete from emp where name='王五'";
            //创建表
            String STR4="create table acc(id Int,name varchar(20)) ";

            //查询该表
            String  str4="select * from emp ";
           st=connection.createStatement();

            rs=st.executeQuery(str4);
            while (rs.next()){
                System.out.print("id" + "\t" + rs.getString(1));
                System.out.print("\t" +"name" + "\t" + rs.getString(2));
                System.out.print("\t" +"gender" + "\t" + rs.getString(3));
                System.out.print("\t" +"salary" + "\t" + rs.getString(4));
                System.out.print("\t" +"join_date" + "\t" + rs.getString(5));
                System.out.println("\t" +"dept_id" + "\t" + rs.getString(6));


            }

            System.out.println(i);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtil.close(st,connection);
        }
    }

}
